/**********************************************************************************************************
** 驱动文件：	jmkt-CyberMateDX.c
** 驱动类型：	jmkt
** 设备名称：	精密空调
** 设备型号：	CyberMateDX
** 设备品牌：	英维克
** 设备协议：	Modbus-RTU
** 驱动描述：	适用于英维克CyberMate精密空调。
** 生成日期：	2020-08-23 00:40:44
**********************************************************************************************************/
#include "Includes.h"


/**********************************************************************************************************
* 定义设备数据点变量结构
**********************************************************************************************************/
typedef struct{
	Var ReturnAirTemp1;							//1#回风温度
	Var ReturnAirTemp2;							//2#回风温度
	Var ReturnAirTemp3;							//3#回风温度
	Var ReturnAirTemp4;							//4#回风温度
	Var ReturnAirTemp5;							//5#回风温度
	Var OutletAirTemp;							//1#出风温度
	Var OutdoorTemp;							//室外温度
	Var ReturnAirHumi1;							//1#回风湿度
	Var ReturnAirHumi2;							//2#回风湿度
	Var ReturnAirHumi3;							//3#回风湿度
	Var ReturnAirHumi4;							//4#回风湿度
	Var ReturnAirHumi5;							//5#回风湿度
	Var OutdoorHumi;							//室外湿度
	Var OutletAirHumi;							//出风湿度
	Var InternalFan;							//内风机
	Var Compressor1;							//1#压缩机
	Var Compressor2;							//2#压缩机
	Var ElectricHeating1;						//1#电加热
	Var ElectricHeating2;						//2#电加热
	Var ElectrodeHumidification;				//电极加湿
	Var ExternalFan1;							//1#外风机
	Var ExternalFan2;							//2#外风机
	Var IFIndoorSolenoidValve;					//IF室内电磁阀
	Var IFOutdoorSolenoidValve1;				//1#IF室外电磁阀
	Var IFOutdoorSolenoidValve2;				//2#IF室外电磁阀
	Var IFRefrigerationPump;					//IF制冷泵
	Var InfraredHumidification;					//红外加湿
	Var UnitOperatingStatus;					//机组运行状态
	Var CoolingState;							//制冷状态
	Var HeatingState;							//加热状态
	Var DehumidificationState;					//除湿状态
	Var TempSetPoint;							//温度设定点
	Var HumiSetPoint;							//湿度设定点
	Var HighTempAlarmPoint;						//高温告警点
	Var LowTempAlarmPoint;						//低温告警点
	Var HighHumiAlarmPoint;						//高湿告警点
	Var LowHumiAlarmPoint;						//低湿告警点
	Var ReturnAirTempAlarm;						//回风温度告警
	Var ReturnAirHumiAlarm;						//回风湿度告警
	Var ReturnAirTempSensor1Fault;				//1#回风温感故障
	Var OutletAirTempSensor1Fault;				//1#出风温感故障
	Var ReturnAirHumiSensorFailure;				//回风湿感故障
	Var DifferentialPressureSensorFailure;		//压差传感器故障
	Var AirLossAlarm;							//气流丢失告警
	Var ScreenCloggingAlarm;					//滤网堵塞告警
	Var ElectrodeHumidificationCurrentAlarm;	//电极加湿电流告警
	Var HumidificationWaterLevelHigh;			//电极加湿水位过高
	Var FloorOverflow;							//地板溢水
	Var PowerSupplyVoltageAlarm;				//电源电压告警
	Var PowerPhaseLossAlarm;					//电源缺相告警
	Var PowerReversePhaseAlarm;					//电源逆相告警
	Var AbnormalPowerFrequency;					//电源频率异常
	Var SystemPressureAlarm;					//系统压力告警
	Var SystemHighPressureLock;					//系统高压锁定
	Var SystemLowPressureLock;					//系统低压锁定
	Var ExhaustTempProtection;					//排气温度保护
	Var ExhaustTempLock;						//排气温度锁定
	Var CoilFrostProtection;					//盘管防冻保护
	Var RefrigerationSystemAbnormal;			//制冷系统异常
	Var ShortPeriodAlarm;						//短周期报警
	Var FrequencyConversionDriveBoardFailure;	//变频驱动板故障
	Var InternalFanFailure;						//内风机故障
	Var InfraredHumiOverTempProtection;			//红外加湿水盘过温保护
	Var InfraredHumiHighWaterLevel;				//红外加湿高水位
	Var InfraredHumiWaterShortage;				//红外加湿缺水
	Var OtherAlarms;							//其它告警
	Var SensorFailure;							//传感器失效
	Var OutdoorInverterCommunicationFailure;	//室外变频器通信故障
	Var PumpCabinetAlarm;						//泵柜告警
}Data_Struct;									//定义变量结构


/**********************************************************************************************************
* 设备数据点变量属性声明
**********************************************************************************************************/
const static Var_Property_Def var_attr[] = {
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirTemp1",
		"1#回风温度",
		"℃",
		"1#回风温度",
		0,
		0,
		"1#回风温度过高",
		"1#回风温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirTemp2",
		"2#回风温度",
		"℃",
		"2#回风温度",
		0,
		0,
		"2#回风温度过高",
		"2#回风温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirTemp3",
		"3#回风温度",
		"℃",
		"3#回风温度",
		0,
		0,
		"3#回风温度过高",
		"3#回风温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirTemp4",
		"4#回风温度",
		"℃",
		"4#回风温度",
		0,
		0,
		"4#回风温度过高",
		"4#回风温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirTemp5",
		"5#回风温度",
		"℃",
		"2#回风温度",
		0,
		0,
		"2#回风温度过高",
		"2#回风温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutletAirTemp",
		"1#出风温度",
		"℃",
		"1#出风温度",
		0,
		0,
		"1#出风温度过高",
		"1#出风温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutdoorTemp",
		"室外温度",
		"℃",
		"室外温度",
		0,
		0,
		"室外温度过高",
		"室外温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirHumi1",
		"1#回风湿度",
		"%",
		"1#回风湿度",
		0,
		0,
		"1#回风湿度过高",
		"1#回风湿度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirHumi2",
		"2#回风湿度",
		"%",
		"2#回风湿度",
		0,
		0,
		"2#回风湿度过高",
		"2#回风湿度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirHumi3",
		"3#回风湿度",
		"%",
		"3#回风湿度",
		0,
		0,
		"3#回风湿度过高",
		"3#回风湿度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirHumi4",
		"4#回风湿度",
		"%",
		"4#回风湿度",
		0,
		0,
		"4#回风湿度过高",
		"4#回风湿度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirHumi5",
		"5#回风湿度",
		"%",
		"5#回风湿度",
		0,
		0,
		"5#回风湿度过高",
		"5#回风湿度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutdoorHumi",
		"室外湿度",
		"%",
		"室外湿度",
		0,
		0,
		"室外湿度过高",
		"室外湿度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutletAirHumi",
		"出风湿度",
		"%",
		"出风湿度",
		0,
		0,
		"出风湿度过高",
		"出风湿度过低",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InternalFan",
		"内风机",
		"",
		"内风机：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"Compressor1",
		"1#压缩机",
		"",
		"1#压缩机：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"Compressor2",
		"2#压缩机",
		"",
		"2#压缩机：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ElectricHeating1",
		"1#电加热",
		"",
		"1#电加热：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ElectricHeating2",
		"2#电加热",
		"",
		"2#电加热：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ElectrodeHumidification",
		"电极加湿",
		"",
		"电极加湿：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ExternalFan1",
		"1#外风机",
		"",
		"1#外风机：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ExternalFan2",
		"2#外风机",
		"",
		"2#外风机：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"IFIndoorSolenoidValve",
		"IF室内电磁阀",
		"",
		"IF室内电磁阀：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"IFOutdoorSolenoidValve1",
		"1#IF室外电磁阀",
		"",
		"1#IF室外电磁阀：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"IFOutdoorSolenoidValve2",
		"2#IF室外电磁阀",
		"",
		"1#IF室外电磁阀：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"IFRefrigerationPump",
		"IF制冷泵",
		"",
		"IF制冷泵：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InfraredHumidification",
		"红外加湿",
		"",
		"红外加湿：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"UnitOperatingStatus",
		"机组运行状态",
		"",
		"机组运行状态：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CoolingState",
		"制冷状态",
		"",
		"制冷状态：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"HeatingState",
		"加热状态",
		"",
		"加热状态：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DehumidificationState",
		"除湿状态",
		"",
		"除湿状态：0-停止；1-运行",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"TempSetPoint",
		"温度设定点",
		"℃",
		"温度设定点",
		0,
		0,
		"温度设定点过高",
		"温度设定点过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"HumiSetPoint",
		"湿度设定点",
		"%",
		"湿度设定点",
		0,
		0,
		"湿度设定点过高",
		"湿度设定点过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"HighTempAlarmPoint",
		"高温告警点",
		"℃",
		"高温告警点",
		0,
		0,
		"高温告警点过高",
		"高温告警点过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"LowTempAlarmPoint",
		"低温告警点",
		"℃",
		"低温告警点",
		0,
		0,
		"低温告警点过高",
		"低温告警点过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"HighHumiAlarmPoint",
		"高湿告警点",
		"%",
		"高湿告警点",
		0,
		0,
		"高湿告警点过高",
		"高湿告警点过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"LowHumiAlarmPoint",
		"低湿告警点",
		"%",
		"低湿告警点",
		0,
		0,
		"低湿告警点过高",
		"低湿告警点过低",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ReturnAirTempAlarm",
		"回风温度告警",
		"",
		"回风温度告警：0-正常；1-高温告警；2-低湿告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ReturnAirHumiAlarm",
		"回风湿度告警",
		"",
		"回风湿度告警：0-正常；1-髙湿告警；2-低湿告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ReturnAirTempSensor1Fault",
		"1#回风温感故障",
		"",
		"1#回风温感故障：0-正常；1-故障告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutletAirTempSensor1Fault",
		"1#出风温感故障",
		"",
		"1#出风温感故障：0-正常；1-故障告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ReturnAirHumiSensorFailure",
		"回风湿感故障",
		"",
		"回风湿感故障：0-正常；1-故障告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DifferentialPressureSensorFailure",
		"压差传感器故障",
		"",
		"压差传感器故障：0-正常；1-故障告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AirLossAlarm",
		"气流丢失告警",
		"",
		"气流丢失告警：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ScreenCloggingAlarm",
		"滤网堵塞告警",
		"",
		"滤网堵塞告警：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ElectrodeHumidificationCurrentAlarm",
		"电极加湿电流告警",
		"",
		"电极加湿电流告警：0-正常；1-过小告警；2-过大告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"HumidificationWaterLevelHigh",
		"电极加湿水位过高",
		"",
		"电极加湿水位过高：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"FloorOverflow",
		"地板溢水",
		"",
		"地板溢水：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PowerSupplyVoltageAlarm",
		"电源电压告警",
		"",
		"电源电压告警：0-正常；1-过压告警；2-低压告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PowerPhaseLossAlarm",
		"电源缺相告警",
		"",
		"电源缺相告警：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PowerReversePhaseAlarm",
		"电源逆相告警",
		"",
		"电源逆相告警：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AbnormalPowerFrequency",
		"电源频率异常",
		"",
		"电源频率异常：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SystemPressureAlarm",
		"系统压力告警",
		"",
		"系统压力告警：0-正常；1-高压告警；2-低压告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SystemHighPressureLock",
		"系统高压锁定",
		"",
		"系统高压锁定：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SystemLowPressureLock",
		"系统低压锁定",
		"",
		"系统低压锁定：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ExhaustTempProtection",
		"排气温度保护",
		"",
		"排气温度保护：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ExhaustTempLock",
		"排气温度锁定",
		"",
		"排气温度锁定：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CoilFrostProtection",
		"盘管防冻保护",
		"",
		"盘管防冻保护：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"RefrigerationSystemAbnormal",
		"制冷系统异常",
		"",
		"制冷系统异常：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ShortPeriodAlarm",
		"短周期报警",
		"",
		"短周期报警：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"FrequencyConversionDriveBoardFailure",
		"变频驱动板故障",
		"",
		"变频驱动板故障：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InternalFanFailure",
		"内风机故障",
		"",
		"内风机故障：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InfraredHumiOverTempProtection",
		"红外加湿水盘过温保护",
		"",
		"红外加湿水盘过温保护：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InfraredHumiHighWaterLevel",
		"红外加湿高水位",
		"",
		"红外加湿高水位：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InfraredHumiWaterShortage",
		"红外加湿缺水",
		"",
		"红外加湿缺水：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OtherAlarms",
		"其它告警",
		"",
		"其它告警：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SensorFailure",
		"传感器失效",
		"",
		"传感器失效：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutdoorInverterCommunicationFailure",
		"室外变频器通信故障",
		"",
		"室外变频器通信故障：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PumpCabinetAlarm",
		"泵柜告警",
		"",
		"泵柜告警：0-正常；1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	}
};


/**********************************************************************************************************
* 函数名称： static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
* 函数说明： 生成获取传感器数据指令
* 输入参数： 指令索引，传感器地址，变量结构体指针,以及指令缓存区指针,指令长度
* 返回参数： 无
**********************************************************************************************************/
static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
{
	switch(index)
	{
		case 0:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x01;								
			cmd[3] = 0x00;
			cmd[4] = 0x00;	
			cmd[5] = 0x42;
			*len = CRC16_Padding(cmd, 6);
			break;
		case 1:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x02;								
			cmd[3] = 0x00;
			cmd[4] = 0x00;	
			cmd[5] = 0x1c;
			*len = CRC16_Padding(cmd, 6);			
			break;
		case 2:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x03;								
			cmd[3] = 0x00;
			cmd[4] = 0x00;	
			cmd[5] = 0x08;
			*len = CRC16_Padding(cmd, 6);			
			break;
		case 3:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x05;								
			cmd[3] = 0x00;
			cmd[4] = 0x00;
			cmd[5] = 0x44;
			*len = CRC16_Padding(cmd, 6);			
			break;	
		case 4:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x05;								
			cmd[3] = 0x4B;
			cmd[4] = 0x00;
			cmd[5] = 0x23;
			*len = CRC16_Padding(cmd, 6);			
			break;				
		default:
			break;
	}
}


/**********************************************************************************************************
* 函数名称： static int parse_fun(short index, int addr, void *data, char *buf, short len)
* 函数说明： 解析传感器响应的数据，并写入数据库
* 输入参数： 解析索引,传感器地址，变量结构体指针，以及响应数据缓存取指针，响应数据长度
* 返回参数： 返回解析结果，返回0成功，返回1失败
**********************************************************************************************************/
static int parse_fun(short index, int addr, void *data, char *buf, short len)
{
	union{
		unsigned short	dat16;
      	unsigned char  	dat8[2];
    }DAT16_8;						   //数据类型转换	
	Data_Struct	*d = (Data_Struct*)data;

	if(buf!=NULL && buf[0]==addr && len>0)
	{	
		if(CRC16_Check(buf,len))
		{
			switch(index)
			{
				case 0:
					DAT16_8.dat8[1] = buf[3];
					DAT16_8.dat8[0] = buf[4];
					d->ReturnAirTemp1.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[5];
					DAT16_8.dat8[0] = buf[6];
					d->ReturnAirTemp2.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[7];
					DAT16_8.dat8[0] = buf[8];
					d->ReturnAirTemp3.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[9];
					DAT16_8.dat8[0] = buf[10];
					d->ReturnAirTemp4.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[11];
					DAT16_8.dat8[0] = buf[12];
					d->ReturnAirTemp5.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[13];
					DAT16_8.dat8[0] = buf[14];
					d->OutletAirTemp.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[19];
					DAT16_8.dat8[0] = buf[20];
					d->OutdoorTemp.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[29];
					DAT16_8.dat8[0] = buf[30];
					d->ReturnAirHumi1.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[31];
					DAT16_8.dat8[0] = buf[32];
					d->ReturnAirHumi2.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[33];
					DAT16_8.dat8[0] = buf[34];
					d->ReturnAirHumi3.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[35];
					DAT16_8.dat8[0] = buf[36];
					d->ReturnAirHumi4.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[37];
					DAT16_8.dat8[0] = buf[38];
					d->ReturnAirHumi5.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[39];
					DAT16_8.dat8[0] = buf[40];
					d->OutdoorHumi.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[41];
					DAT16_8.dat8[0] = buf[42];
					d->OutletAirHumi.value.fnum = DAT16_8.dat16*0.1;
					break;
				case 1:
					SetStringDataPoint(&d->InternalFan,				buf[ 4]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->Compressor1,				buf[ 6]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->Compressor2,				buf[ 8]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->ElectricHeating1,		buf[10]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->ElectricHeating2,		buf[12]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->ElectrodeHumidification,	buf[16]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->ExternalFan1,			buf[18]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->ExternalFan2,			buf[20]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->IFIndoorSolenoidValve,	buf[26]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->IFOutdoorSolenoidValve1,	buf[28]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->IFOutdoorSolenoidValve2,	buf[30]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->IFRefrigerationPump,		buf[32]==1, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->InfraredHumidification,	buf[36]==1, ON, OFF, "运行", "停止");
				
					SetStringDataPoint(&d->UnitOperatingStatus,		1, Normal, Alarm, "运行", "停止");
					SetStringDataPoint(&d->CoolingState,			0, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->HeatingState,			0, ON, OFF, "运行", "停止");
					SetStringDataPoint(&d->DehumidificationState,	0, ON, OFF, "运行", "停止");
				
//					SetStringDataPoint(&d->UnitOperatingStatus,		buf[44]==1, Normal, Alarm, "运行", "停止");
//					SetStringDataPoint(&d->CoolingState,			buf[54]==1, ON, OFF, "运行", "停止");
//					SetStringDataPoint(&d->HeatingState,			buf[56]==1, ON, OFF, "运行", "停止");
//					SetStringDataPoint(&d->DehumidificationState,	buf[58]==1, ON, OFF, "运行", "停止");
					break;
				case 2:
					DAT16_8.dat8[1] = buf[3];
					DAT16_8.dat8[0] = buf[4];
					d->TempSetPoint.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[7];
					DAT16_8.dat8[0] = buf[8];
					d->HumiSetPoint.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[11];
					DAT16_8.dat8[0] = buf[12];
					d->HighTempAlarmPoint.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[13];
					DAT16_8.dat8[0] = buf[14];
					d->LowTempAlarmPoint.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[15];
					DAT16_8.dat8[0] = buf[16];
					d->HighHumiAlarmPoint.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[17];
					DAT16_8.dat8[0] = buf[18];
					d->LowHumiAlarmPoint.value.fnum = DAT16_8.dat16*0.1;
					break;
				case 3:
					if(buf[4]==1){
						SetStringDataPoint(&d->ReturnAirTempAlarm,		1, Alarm, Normal, "高温告警", "正常");
					}
					else if(buf[6]==1){
						SetStringDataPoint(&d->ReturnAirTempAlarm,		1, Alarm, Normal, "低温告警", "正常");
					}
					else{
						SetStringDataPoint(&d->ReturnAirTempAlarm,		0, Alarm, Normal, "告警", "正常");
					}
					
					if(buf[8]==1){
						SetStringDataPoint(&d->ReturnAirHumiAlarm,		1, Alarm, Normal, "髙湿告警", "正常");
					}
					else if(buf[10]==1){
						SetStringDataPoint(&d->ReturnAirHumiAlarm,		1, Alarm, Normal, "低湿告警", "正常");
					}
					else{
						SetStringDataPoint(&d->ReturnAirHumiAlarm,		0, Alarm, Normal, "告警", "正常");
					}
					
					SetStringDataPoint(&d->ReturnAirTempSensor1Fault,			buf[12]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->OutletAirTempSensor1Fault,			buf[18]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->ReturnAirHumiSensorFailure,			buf[24]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->DifferentialPressureSensorFailure,	buf[26]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->AirLossAlarm,						buf[48]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->ScreenCloggingAlarm,					buf[50]==1, Alarm, Normal, "告警", "正常");
					
					if(buf[56]==1){
						SetStringDataPoint(&d->ElectrodeHumidificationCurrentAlarm,		1, Alarm, Normal, "过小告警", "正常");
					}
					else if(buf[58]==1){
						SetStringDataPoint(&d->ElectrodeHumidificationCurrentAlarm,		1, Alarm, Normal, "过大告警", "正常");
					}
					else{
						SetStringDataPoint(&d->ElectrodeHumidificationCurrentAlarm,		0, Alarm, Normal, "告警", "正常");
					}

					SetStringDataPoint(&d->HumidificationWaterLevelHigh,		buf[60]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->FloorOverflow,						buf[62]==1, Alarm, Normal, "告警", "正常");
					
					if(buf[64]==1){
						SetStringDataPoint(&d->PowerSupplyVoltageAlarm,		1, Alarm, Normal, "过压告警", "正常");
					}
					else if(buf[66]==1){
						SetStringDataPoint(&d->PowerSupplyVoltageAlarm,		1, Alarm, Normal, "低压告警", "正常");
					}
					else{
						SetStringDataPoint(&d->PowerSupplyVoltageAlarm,		0, Alarm, Normal, "告警", "正常");
					}

					SetStringDataPoint(&d->PowerPhaseLossAlarm,					buf[68]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->PowerReversePhaseAlarm,				buf[70]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->AbnormalPowerFrequency,				buf[72]==1, Alarm, Normal, "告警", "正常");
					
					if(buf[86]==1||buf[90]==1){
						SetStringDataPoint(&d->SystemPressureAlarm,		1, Alarm, Normal, "高压告警", "正常");
					}
					else if(buf[88]==1||buf[92]==1){
						SetStringDataPoint(&d->SystemPressureAlarm,		1, Alarm, Normal, "低压告警", "正常");
					}
					else{
						SetStringDataPoint(&d->SystemPressureAlarm,		0, Alarm, Normal, "告警", "正常");
					}

					SetStringDataPoint(&d->SystemHighPressureLock,				(buf[ 94]==1||buf[ 96]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->SystemLowPressureLock,				(buf[ 98]==1||buf[100]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->ExhaustTempProtection,				(buf[102]==1||buf[104]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->ExhaustTempLock,						(buf[106]==1||buf[108]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->CoilFrostProtection,					(buf[110]==1||buf[112]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->RefrigerationSystemAbnormal,			(buf[114]==1||buf[116]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->ShortPeriodAlarm,					(buf[118]==1||buf[120]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->FrequencyConversionDriveBoardFailure,(buf[122]==1||buf[124]==1), Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->InternalFanFailure,					buf[132]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->InfraredHumiOverTempProtection,		buf[134]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->InfraredHumiHighWaterLevel,			buf[136]==1, Alarm, Normal, "告警", "正常");
					SetStringDataPoint(&d->InfraredHumiWaterShortage,			buf[138]==1, Alarm, Normal, "告警", "正常");
					break;
				case 4:
					SetStringDataPoint(&d->SensorFailure, (
						buf[ 4]==1||
						buf[ 6]==1||
						buf[ 8]==1||
						buf[10]==1||
						buf[12]==1||
						buf[14]==1||
						buf[16]==1||
						buf[18]==1||
						buf[20]==1||
						buf[22]==1||
						
						buf[30]==1||
						buf[32]==1
					), Alarm, Normal, "告警", "正常");
					
					SetStringDataPoint(&d->OutdoorInverterCommunicationFailure,	(buf[24]==1||buf[26]==1), Alarm, Normal, "告警", "正常");
					
					SetStringDataPoint(&d->PumpCabinetAlarm,(
						buf[34]==1||
						buf[36]==1||
						buf[38]==1||
						buf[40]==1||
						buf[42]==1||
						buf[44]==1
					), Alarm, Normal, "告警", "正常");
					
					SetStringDataPoint(&d->OtherAlarms,(
						buf[28]==1||
						buf[46]==1||
						buf[48]==1||
						buf[72]==1
					), Alarm, Normal, "告警", "正常");		
					break;
				default:
					break;
			}
			return 0;
		}
	}
	return 1;
}


/**********************************************************************************************************
* 函数名称： void jmkt_CyberMateDX_Registration(void)
* 函数说明： 精密空调驱动注册
* 输入参数： 无
* 返回参数： 无
**********************************************************************************************************/
void jmkt_CyberMateDX_Registration(void)
{
	DeviceDriverRegistration(
		"jmkt",													//设备类型
		"精密空调",												//设备名称（导航栏默认显示名称）
		"英维克",												//设备品牌
		"CyberMateDX",											//设备型号
		"适用于英维克CyberMate精密空调。",						//驱动描述
		var_attr,												//变量属性声明
		sizeof(Data_Struct),									//变量结构体空间大小
		cmd_fun,												//发送指令生成函数
		parse_fun,												//数据解析函数
		500														//设备响应超时时间
	);
		
#if 0 || VirtualFrameEN
	#define	CMD1	"\x01\x03\x01\x00\x00\x42\xC4\x07"
	#define	RSP1	"\x01\x03\x4E\x00\xF1\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x00\xC2\x00\x00\x00\x00\x7F\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x02\x2E\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x00\x00\x00\x00\x00\x13\x00\xEE\x00\x00\x00\x00\x05\xB6\x7F\xFF\x7F\xFF\x7F\xFF\x00\xFE\x7F\xFF\x00\xAE\x7F\xFF\x02\x2A\x7F\xFF\x00\x00\x00\x00\xD3\x51"
	#define	CMD2	"\x01\x03\x02\x00\x00\x1C\x45\xBB"
	#define	RSP2	"\x01\x03\x28\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6F\x36"
	#define	CMD3	"\x01\x03\x03\x00\x00\x08\x44\x48"
	#define	RSP3	"\x01\x03\x10\x01\x04\x00\x28\x01\xC2\x00\x32\x01\x5E\x00\x50\x03\x20\x00\x64\xB8\x9B"
	#define	CMD4	"\x01\x03\x05\x00\x00\x44\x45\x35"
	#define	RSP4	"\x01\x03\x88\x00\x00\x00\x00\x00\x20\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x20\x00\x00\x00\x20\x00\x00\x00\x20\x00\x00\x00\x20\x00\x00\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x00\x00\x00\x00\x00\x00\x20\x00\x20\x00\x20\x00\x20\xDE\xAF"		
	#define	CMD5	"\x01\x03\x05\x4B\x00\x23\x74\xC9"
	#define	RSP5	"\x01\x03\x34\x00\x00\x00\x20\x00\x00\x00\x20\x00\x00\x00\x20\x00\x20\x00\x20\x00\x00\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x20\x00\x00\x00\x00\x00\x00\xE6\x78"		

	VirtualFrameRegistration(CMD1,  sizeof(CMD1)-1,  RSP1,  sizeof(RSP1)-1);
	VirtualFrameRegistration(CMD2,  sizeof(CMD2)-1,  RSP2,  sizeof(RSP2)-1);
	VirtualFrameRegistration(CMD3,  sizeof(CMD3)-1,  RSP3,  sizeof(RSP3)-1);
	VirtualFrameRegistration(CMD4,  sizeof(CMD4)-1,  RSP4,  sizeof(RSP4)-1);
	VirtualFrameRegistration(CMD5,  sizeof(CMD5)-1,  RSP5,  sizeof(RSP5)-1);
#endif	
}

